<?php
namespace App\Traits;

use App\Services\Api\Api;
trait MarketTrait
{
    use CacheTrait;
    /**
     * 获取服务商列表
     * @param  [type] $request [description]
     * @param  [type] $apiCode [description]
     * @return [type]          [description]
     */
    public function getFilterServicer($request, $apiCode)
    {
        $obj = new Api();
        $formData = [
            'name' => $request->input('title', ''),
            'areaId' => $request->input('area', -1),
            'domainId' => $request->input('domain', -1),
            'techRouteId' => $request->input('tech_route', -1),
            'pageNo' => $request->input('page', 1),
            'pageSize' => $request->input('limit', 10),
        ];
        $postData = $obj->getJavaPostData($apiCode, $formData);
        $result = $obj->getJavaResponseData($postData);
        if ($result) {
            return [
                'dataList' => $result['custs'],
                'pageCount' => $result['pageTotal'],
            ];
        }
        return false;
    }

    public function getNeedsList($apiCode)
    {

        $obj = new Api();
        $formData = [
            'pageNo' => 1,
            'pageSize' => 5,
        ];
        $postData = $obj->getJavaPostData($apiCode, $formData);
        $result = $obj->getJavaResponseData($postData);
        return $this->cacheGetMarketNeedsList($result);

    }

    public function getProjectAdList($apiCode)
    {
        $obj = new Api();
        $formData = [
            'pageNo' => 1,
            'pageSize' => 6,
        ];
        $postData = $obj->getJavaPostData($apiCode, $data);
        $result = $obj->getJavaResponseData($postData);
        return $this->cacheGetMarketProjectAdList($result);
    }
}
